<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%

    Cookie cookie = new Cookie("name", "dearHaoGeGe");
    //设置cookie的最大时效时间以秒为单位，如果为0 表示理解删除该cookie，若为负数表示不存储该cookie
    cookie.setMaxAge(30);
    response.addCookie(cookie);

    Cookie[] cookies = request.getCookies();

    if (cookies != null && cookies.length > 0) {
        for (Cookie c : cookies) {
            out.print(c.getName() + " : " + c.getValue());
            out.print("<br/>");
        }
    }


%>
</body>
</html>
